package com.markhsiu.httpserver;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import com.markhsiu.httpserver.event.HttpEvent;
import com.markhsiu.httpserver.pool.ThreadPool;

public class Server {

	public static void main(String[] args) {
		Server server = new Server();
		try {
			server.start();
		} catch (IOException e) {
			  e.printStackTrace();
		      System.exit(1);
		}
	}

	private int port = 8080;
	
	@SuppressWarnings("resource")
	public void start() throws IOException {

		ServerSocket server = new ServerSocket(port);
		while (true) {
			Socket socket = server.accept();
			ThreadPool.execute(new HttpEvent(socket));	 
		}
	}
 
}
